function varargout = subsref(lst, S)
%SUBSREF Implements the subscript-based accessing with cell array convention
%
% [ Syntax ]
%   - sublist = lst(indices)
%   - e = lst{index}
%   - [e1, e2, ...] = lst{indices}
%   - [v1, v2, ...] = S.fname
%
% [ Description ]
%   - sublist = lst(indices) gets a sub-list containing the elements 
%     specified by the input indices. 
%
%     Specially, if indices is a scalar, it returns a sublist with 
%     one element.
%
%   - e = lst{index} gets an element in the list of the specified index.
%
%   - [e1, e2, ...] = lst{indices} returns multiple elements of the
%     specified indices.
%
%   - [v1, v2, ...] = S.fname returns the fields of all elements.
%
% [ Remarks ]
%   - It simply wrapps the subscript-reference of the internal cell
%     array representation.
%
%   - Only one-dimensional subscripts is allowed. 
%
% [ History ]
%   - Created by Dahua Lin, on Jan 5, 2008
%

%% main

switch S(1).type
    case '{}'
        [varargout{1:nargout}] = subsref(lst.items, S);
                
    case '()'
        
        if length(S(1).subs) > 1
            error('sltoolbox:sllist:invalidsubs', ...
                'Only one-dimensional subscript-accessing is supported for sllist.');
        end
        
        varargout{1} = sllist(subsref(lst.items, S));
        
    case '.'
        error('sltoolbox:sllist:invalidsubs', ...
            'dot-indexing is not supported for sllist');        
end

